// ==UserScript==
// @name         Baidu Adblock
// @namespace    https://gitee.com/hziee514/
// @version      0.1
// @description  block ads in baidu.com
// @author       46084337@qq.com
// @match        *://*.baidu.com/*
// @match        *://baidu.com/*
// @icon         
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    function blockAds(node){
        if (node.hasAttribute && node.hasAttribute('data-placeid')) {
            console.log('block baidu AD:', node);
            node.style.display = 'none';
        }
    }
    const observer = new MutationObserver(function(mutations){
        mutations.forEach(function(mutation){
            mutation.addedNodes.forEach(blockAds);
        });
    });
    observer.observe(document.head, {childList:true});
    window.addEventListener('DOMContentLoaded', function() {
        observer.observe(document.body, { childList: true, subtree: true });
    });
})();